%module biosignal

/* Convert from C --> Octave */

%inline %{
#include <ov-list.h>
class dVector : public Array<double> {
public:
	dVector(double *d, int len) : Array<double>(d, dim_vector(1,len)) {
	}
};

%}

%typemap(out) std::list<Data> {

	int length = $1.size();
	Cell data(dim_vector(length,1));
	std::list<Data>::iterator it;
	
	int i =0;
	for (it=$1.begin() ; it != $1.end(); it++ ) {
		dVector dx((*it).data, (*it).values);		
		data(i)=RowVector(dx);
		i++;
		
	}
	
    $result = octave_list(data).list_value();
}

%include "biosignal_common.i"



%define POINTER_TO_OCTAVE_VALUE(KLASS_NAME)
%inline %{
octave_value KLASS_NAME ## _to_value( KLASS_NAME * pobj ) {
	octave_value _outv;
	_outv = SWIG_NewPointerObj(SWIG_as_voidptr(pobj), SWIGTYPE_p_ ## KLASS_NAME, 0 );
	return _outv;
}
%}	
%enddef
%define CONST_POINTER_TO_OCTAVE_VALUE(KLASS_NAME)
%inline %{
octave_value KLASS_NAME ## _to_value( const KLASS_NAME * pobj ) {
	octave_value _outv;
	_outv = SWIG_NewPointerObj(SWIG_as_voidptr(pobj), SWIGTYPE_p_ ## KLASS_NAME, 0 );
	return _outv;
}
%}	
%enddef

POINTER_TO_OCTAVE_VALUE( BioSignal )
CONST_POINTER_TO_OCTAVE_VALUE( BioSignal )

POINTER_TO_OCTAVE_VALUE( TimePeriod )
POINTER_TO_OCTAVE_VALUE( TimePoint )
POINTER_TO_OCTAVE_VALUE( TimeOffset )

